﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Athanor.Gui
{
    public class AnimatedSprite : Sprite
    {
        Dictionary<String, Animation> animations = new Dictionary<String, Animation>();
        String currentAnimationName;
        Animation currentAnimation;

        public AnimatedSprite() : base(0, 0) { }

        public void setAnimation(string name)
        {
            if (name != currentAnimationName)
            {
                currentAnimation = animations[name];
                currentAnimationName = name;
            }
            currentAnimation.startAnim(true);
        }

        public void AddAnimation(string _name, Animation _animation)
        {
            animations[_name] = _animation;
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            currentAnimation.update(gameTime);
            Texture = currentAnimation.getTexture();
            Source = currentAnimation.getRect();
        }
    }
}
